<template>
    <section>
        <el-upload
            class="upload-demo"
            drag
            :headers="headers"
            action="/fileApi/manage/file/uploadFile"
            accept=".pdf,.doc,.docx,.xls,.xlsx"
            multiple
        >
            <el-icon class="el-icon--upload"><upload-filled /></el-icon>
            <div class="el-upload__text">
            将附件拖到此处或者 <em>点击上传</em>
            </div>
            <template #tip>
            </template>
        </el-upload>
    </section>
</template>

<script setup lang="ts">
import { UploadFilled } from '@element-plus/icons-vue'
import { Session } from '/@/utils/storage';
import { reactive, defineExpose ,ref,watch,onMounted} from 'vue'

const state = reactive({
    fileList: [
        { fileName: '', filePath: ''}
    ]
})

const props = defineProps({
  active: Boolean
})

// 获取数据
const getData = () => state.fileList;
const headers = ref({Authorization: ''})
const setHeader = () => {
  const token = `${Session.get('token')}`
    headers.value.Authorization = token;
    console.log('设置请求头')
}
// 暴露获取表单数据方法
defineExpose({ getData,setHeader })
</script>
